<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
    <script>
        function loadImage(src){
            return new Promise((resolve,reject)=>{
                let image = new Image();
                image.src = src
                document.body.appendChild(image)
                image.onload = ()=>{
                    resolve(image)
                }
                image.onerror = reject
            })
        }

        loadImage('https://picsum.photos/200/300').then(image=>{
            console.log(image)
        })
    </script>
</body>
</html>